package ljl.codetop;

public class _153_find_min {

    /**
     * 这个简单，比 33 题
     *
     * todo 操他妈出师不利，上来就错了
     */
    static class a {
        // [4,5,6,7,0,1,2]
        // [3,1,2]
        public int findMin(int[] nums) {
            int l = 0, r = nums.length - 1;
            int res = nums[0];
            while (l <= r) {
                int mid = (l + r) >>> 1;
                if (nums[mid] <=
                        // todo 我日这里必须是最右端，不能用 r
                        nums[nums.length - 1]) {
                    res = nums[mid];
                    r = mid - 1;
                } else {
                    l = mid + 1;
                }
            }
            return res;
        }
    }

    /**
     * 比我的好一截子
     */
    static class off1 {
        public int findMin(int[] nums) {
            int l = 0, r = nums.length - 1;
            while (l < r) {
                int mid = (l + r) >>> 1;
                if (nums[mid] < nums[r])
                    r = mid;
                else l = mid + 1;
            }
            return nums[l];
        }
    }
}
